//
//  MyWalletVC.m
//  Logistics
//
//  Created by enzhoukeji on 2018/8/10.
//  Copyright © 2018年 puyue.com. All rights reserved.
//

#import "MyWalletVC.h"
#import "TransactionRecordsVC.h"
#import "YMDatePickView.h"
#import "AddBankCardVC.h"
#import "AddAlipayVC.h"
#import "WithdrawalVC.h"
@interface MyWalletVC ()
@property (nonatomic,strong) UIView *headView;
@property (nonatomic,strong) UIView *secondView;

@end

@implementation MyWalletVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navTitle = @"我的钱包";
    self.view.backgroundColor = [UIColor colorWithRed:243/255.0 green:243/255.0 blue:243/255.0 alpha:1];
    // Do any additional setup after loading the view.
    [self createUIView];
}
-(void)createUIView {
    self.headView = [UIView new];
    self.headView.backgroundColor = [UIColor whiteColor];
    UILabel * balanceLabel = [UILabel labelWithSize:[UIFont systemFontOfSize:13] withColor:nil withText:@"余额（元）"];
    UILabel * amountLabel = [UILabel labelWithSize:[UIFont systemFontOfSize:25] withColor:nil withText:@"22"];
    UILabel * noCanLabel = [UILabel labelWithSize:[UIFont systemFontOfSize:14] withColor:nil withText:@"不可提现金额（元）：  23312"];
    UIButton * withdrawalBtn = [UIButton buttonWithTitle:@"提现" withImageName:nil withBGColor:nil Withlayer:NO];
    [withdrawalBtn setTitleColor:[UIColor colorWithRed:106/255.0 green:181/255.0 blue:231/255.0 alpha:1] forState:UIControlStateNormal];
    withdrawalBtn.layer.cornerRadius = 5.0;
    withdrawalBtn.layer.borderColor = [UIColor colorWithRed:106/255.0 green:181/255.0 blue:231/255.0 alpha:1].CGColor;
    withdrawalBtn.layer.borderWidth = 1.0;
    [withdrawalBtn addTarget:self action:@selector(withdrawalBtnClieck:) forControlEvents:UIControlEventTouchUpInside];
    
    self.secondView = [UIView new];
    self.secondView.backgroundColor = [UIColor whiteColor];
    UILabel * lifeLabel = [UILabel labelWithSize:[UIFont systemFontOfSize:13] withColor:nil withText:@"生活方式"];
    UIButton * bankCardBtn = [UIButton buttonWithTitle:@"我的账户" withImageName:@"wodezhanghu" withBGColor:nil Withlayer:NO];
    [bankCardBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [bankCardBtn setImageEdgeInsets:UIEdgeInsetsMake(10, 50, 30,  0)];
    [bankCardBtn setTitleEdgeInsets:UIEdgeInsetsMake(50, 10, 0, 50)];
    bankCardBtn.titleLabel.font = [UIFont systemFontOfSize:13];
    [bankCardBtn addTarget:self action:@selector(bankCardBtnClicek:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton * recordsBtn = [UIButton buttonWithTitle:@"交易记录" withImageName:@"jiaoyijilu" withBGColor:nil Withlayer:NO];
    [recordsBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [recordsBtn setImageEdgeInsets:UIEdgeInsetsMake(10, 50, 30,  0)];
    [recordsBtn setTitleEdgeInsets:UIEdgeInsetsMake(50, 10, 0, 50)];
    recordsBtn.titleLabel.font = [UIFont systemFontOfSize:13];
    [recordsBtn addTarget:self action:@selector(recordsBtnClicek:) forControlEvents:UIControlEventTouchUpInside];
    
    
    [self.view addSubview:self.headView];
    [self.headView addSubview:balanceLabel];
    [self.headView addSubview:amountLabel];
    [self.headView addSubview:noCanLabel];
    [self.headView addSubview:withdrawalBtn];
    [self.view addSubview:self.secondView];
    [self.secondView addSubview:lifeLabel];
    [self.secondView addSubview:bankCardBtn];
    [self.secondView addSubview:recordsBtn];
    
    [self.headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(kMainTopHeight);
        make.left.mas_equalTo(0);
        make.height.mas_equalTo((kMainScreen_height- kMainTopHeight)/4);
        make.width.mas_equalTo(kMainScreen_width);
    }];
    [balanceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(GTFixHeightFlaot(10));
        make.left.mas_equalTo(GTFixWidthFlaot(20));
        make.height.mas_equalTo(GTFixHeightFlaot(15));
        make.width.mas_equalTo(balanceLabel.mas_width);
    }];
    [amountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(balanceLabel.mas_bottom).offset(GTFixHeightFlaot(15));
        make.left.mas_equalTo(GTFixWidthFlaot(20));
        make.height.mas_equalTo(GTFixHeightFlaot(40));
        make.width.mas_equalTo(amountLabel.mas_width);
    }];
    [noCanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(amountLabel.mas_bottom).offset(GTFixHeightFlaot(15));
        make.left.mas_equalTo(GTFixWidthFlaot(20));
        make.height.mas_equalTo(GTFixHeightFlaot(15));
        make.width.mas_equalTo(noCanLabel.mas_width);
    }];
    [withdrawalBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kMainScreen_width/2 + GTFixWidthFlaot(40));
        make.height.mas_equalTo(GTFixHeightFlaot(25));
        make.width.mas_equalTo(GTFixWidthFlaot(70));
        make.centerY.mas_equalTo(amountLabel.mas_centerY);
    }];
    [self.secondView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.headView.mas_bottom).offset(GTFixHeightFlaot(10));
        make.left.mas_equalTo(0);
        make.height.mas_equalTo(GTFixHeightFlaot(100));
        make.width.mas_equalTo(kMainScreen_width);
    }];
    [lifeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(GTFixHeightFlaot(10));
        make.left.mas_equalTo(GTFixWidthFlaot(15));
        make.height.mas_equalTo(GTFixHeightFlaot(15));
        make.width.mas_equalTo(lifeLabel.mas_width);
    }];
    [bankCardBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(lifeLabel.mas_bottom).offset(0);
        make.left.mas_equalTo(GTFixWidthFlaot(0));
        make.bottom.mas_equalTo(GTFixHeightFlaot(0));
        make.width.mas_equalTo(kMainScreen_width/2);
    }];
    [recordsBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(lifeLabel.mas_bottom).offset(0);
        make.left.mas_equalTo(bankCardBtn.mas_right).offset(0);
        make.bottom.mas_equalTo(GTFixHeightFlaot(0));
        make.width.mas_equalTo(kMainScreen_width/2);
    }];
}
-(void)withdrawalBtnClieck:(UIButton *)btn {
    WithdrawalVC * vc = [WithdrawalVC new];
    [self.navigationController pushViewController:vc animated:YES];
}
-(void)bankCardBtnClicek:(UIButton *)btn {
    YMDatePickView *city = [[YMDatePickView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) selectItemTitle:@"您还未绑定账户，请选择要绑定的账户"];
    [city showItemView:^(NSIndexPath *dateString) {
        if (dateString.row == 0) {
            AddBankCardVC * vc = [AddBankCardVC new];
            [self.navigationController pushViewController:vc animated:YES];
        }else if(dateString.row == 1){
            AddAlipayVC * vc = [AddAlipayVC new];
            [self.navigationController pushViewController:vc animated:YES];
        }else{
            ZFLog(@"微信");
        }
    }];
}
-(void)recordsBtnClicek:(UIButton *)btn {
    TransactionRecordsVC * vc = [TransactionRecordsVC new];
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
